/**
 * All rights Reserved, Copyright (C) HAOWU LIMITED 2011-2015
 * FileName: VelocitysScrollView.java
 * @author RENJIE
 */

package com.handmark.pulltorefresh.library;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.OverScroller;
import android.widget.ScrollView;

/**
 * name: VelocitysScrollView <BR>
 * description: please write your description <BR>
 * create date: 2015年10月16日
 * 
 * @author: HAOWU) RENJIE
 */
@SuppressLint("NewApi")
public class VelocityScrollView extends ScrollView {

    private OverScroller mScroller;

    public VelocityScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mScroller = new OverScroller(context);
    }

    public void startScroll(int startX, int startY, int dx, int dy, int duration) {
        mScroller.startScroll(startX, startY, dx, dy, duration);
        invalidate();
    }

    public void forceFinished() {
        mScroller.forceFinished(true);
    }

    public boolean isFinished() {
        return mScroller.isFinished();
    }

    @Override
    public void computeScroll() {

        if (mScroller.computeScrollOffset()) {
            scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
            postInvalidate();
        }
        super.computeScroll();
    }

 

}
